Ruby class: Array
| array | another array |
| epsilon | threshold accuracy |
| returns | true iff the arrays are equal, with a margin stablished by epsilon |
# File lib/data-structures.rb, line 7
7: def eql_eps(array, epsilon)
8: if array.length != self.length
9: return false
10: end
11: i = 0
12: result = true
13: while i < self.length && result
14: a = self[i]
15: b = array[i]
16: dif = a - b
17: if dif < 0
18: dif = 1*dif
19: end
20: result = (dif < epsilon)
21: i+=1
22: end
23: return result
24: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.